//
//  WeakTargetObject.m
//  CycleImageScrollDemo
//
//  Created by 郑佳 on 16/6/17.
//  Copyright © 2016年 Triangle. All rights reserved.
//

#import "WeakTargetObject.h"

@interface WeakTargetObject ()

@property (nonatomic, weak) id target;
@property (nonatomic, assign) SEL selector;

@end

@implementation WeakTargetObject

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(nullable id)userInfo repeats:(BOOL)yesOrNo{
    
    WeakTargetObject *object = [[WeakTargetObject alloc]init];
    object.target = aTarget;
    object.selector = aSelector;
    
    return [NSTimer scheduledTimerWithTimeInterval:ti target:object selector:@selector(fire:) userInfo:userInfo repeats:yesOrNo];
}

- (void)fire:(id)obj{
    [self.target performSelector:self.selector withObject:obj];
}
@end
